package com.e3.basdoc.employeecls.client;

import java.util.List;

import com.e3.basdoc.employeecls.model.EmployeeClsModel;
import com.e3.template.tgf.TGFTreePanelAsync;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class EmployeeClsTreePanel extends TGFTreePanelAsync<EmployeeClsModel> {
	
	private EmployeeClsRPCServiceAsync service = EmployeeClsRPCService.Util.getInstance();

	@Override
	public String getTreeDisplayFieldName() {
		return EmployeeClsModel.NAME;
	}

	@Override
	public void onTreeLoadSuccess(EmployeeClsModel parent, List<EmployeeClsModel> result) {
		if(result!=null&&result.size()==1){
			EmployeeClsModel model = result.get(0);
			if(EmployeeClsHelper.INSTANCE.isRootModel(model)){
				model.setName(EmployeeClsMessages.INSTANCE.tree_root_name());
			}
		}
	}

	@Override
	public void excuteLoadModelChildren(final EmployeeClsModel pModel,AsyncCallback<List<EmployeeClsModel>> callback) {
		service.getEmployeeClsChildren(pModel,callback);
	}

	@Override
	public String getRootDisplayName() {
		return EmployeeClsMessages.INSTANCE.tree_root_name();
	}

	@Override
	protected boolean isRootModel(EmployeeClsModel model) {
		return EmployeeClsHelper.INSTANCE.isRootModel(model);
	}

}
